#include "public.h"
#include "smg.h"
#include "smg.c"
#include "DS18B20.h"

int arr[17] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void main()
{
    unsigned char i = 0;
    int temp_value =0;
    unsigned char temp_buf[5];
    DS18B20_init();
    while(1)
    {
        i++;
        if (i%50==0)
        {
            temp_value = DS18B20_read_temperture()*10;
        }
        if (temp_value<0)
        {
            temp_value = -temp_value;
            temp_buf[0] = 0x40;
        }
        else
            {
                temp_buf[0] = 0x00;
                temp_buf[1] = arr[temp_value/1000];
                temp_buf[2] = arr[temp_value%1000/100];
                temp_buf[3] = arr[temp_value%1000%100/10]|0x80;
                temp_buf[4] = arr[temp_value%1000%100%10];
            smg_display(temp_buf,4);
            }
    }
}